<?php 
class IndexController extends commonController{
	public function __construct(){
		parent::__construct();
		$this->showList();
	}
	public function index(){
		//大栏目
		$cate = M('wenda')->query('SELECT * FROM hd_category WHERE pid=0');
		foreach($cate as $k => $v){
			//二级栏目
			$cate[$k]['son'] = M('category')->query("SELECT * FROM hd_category where pid= {$v['cid']}");
		}
		$this->assign('cate',$cate);
		$this->topCate();
		$this->display();
	}
	/*
	 * 一级栏目调用
	 */
	public function topCate(){
		//一级
		$topCate = M('wenda')->query('SELECT * FROM hd_category WHERE pid=0');
//		二级
		
		$this->assign('topCate',$topCate);
	}

	/*
	 * 显示列表内容 
	 */
	public function showList(){
		// 未解决
		$listValue = M('wenda')->query("SELECT * FROM hd_ask WHERE solve =0 ORDER BY TIME DESC   limit 5 ");
		$this->assign('showList',$listValue);
		// 高分悬赏
		$hightScro = M('wenda')->query("SELECT * FROM hd_ask WHERE solve =0 and reward>=20 order by reward desc limit 5 ");
		$this->assign('hightScro',$hightScro);
		//已解决问题
		$okAnswer = M('wenda')->query("SELECT * FROM hd_ask WHERE solve =1 ORDER BY TIME DESC   limit 5 ");
		$this->assign('okAnswer',$okAnswer);
	}

}
?>